﻿using System.Collections.Generic;
using System.Linq;
using yiCommerce.Core.Domain.ShoppingCarts;

namespace yiCommerce.Service.Orders
{
    public class OrderTotalCalculationService:IOrderTotalCalculationService
    {
        public void GetShoppingCartSubTotal(IList<ShoppingCartItem> cart, out decimal subTotalWithoutDiscountBase2)
        {
            subTotalWithoutDiscountBase2  = cart.Sum(c => c.Quantity*c.ProductVariant.Price);
        }

        public decimal? GetShoppingCartShippingTotal(IList<ShoppingCartItem> cart)
        {
            return 0;
        }

        public decimal? GetShoppingCartTotal(IList<ShoppingCartItem> cart)
        {
            var subTotal = (decimal) 0;
            GetShoppingCartSubTotal(cart, out subTotal);
            return this.GetShoppingCartShippingTotal(cart) + subTotal;
        }
    }
}